/*kvan
 *2014.5.12
 */
package com.taxsystem.likaifan.vehicletaxcheck;

import java.util.concurrent.ExecutionException;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.main.taxsystem.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class VehicleTaxCheckResult extends Activity {

	public final static String RECI_COAST = "sw.system.HTTUTIL";
	private TextView year;
	private TextView tax_amount;
	private TextView delay_amount;
	private TextView fine_amount;
	private TextView bujiao;


	private Button button;
	

	final int MY_NOTICE = 0x111;
	final int NAV_SETTING = 0x112;
	final int ACCOUNT_SETTING = 0x113;
	final int INDIVIDUAL_SETTING = 0x114;
	private String requestUrl;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.vehicle_tax_check_result);
		// 注册广播
		year = (TextView) findViewById(R.id.year);
		tax_amount = (TextView) findViewById(R.id.tax_amount);
		delay_amount = (TextView) findViewById(R.id.delay_amount);
		fine_amount = (TextView) findViewById(R.id.fine_amount);
		bujiao = (TextView) findViewById(R.id.bujiao);

		Intent intent = getIntent();
		//String result = intent.getStringExtra("result");
		
		//savedInstanceState = getIntent().getExtras();
		Log.d("duck",intent.getStringExtra("result") );
		try {
			JSONObject result = new JSONObject(intent.getStringExtra("result"));
			JSONObject data = new JSONObject(result.getString("data"));
			if(data.getString("retCode").equals("1"))
			{
				JSONArray taxInfoList = data.getJSONArray("taxInfoList");
				Log.d("duck",data.getString("queryMsg") );
				Log.d("duck",taxInfoList.getJSONObject(0).getString("year") );
				/*
				String[] taxInfoArray = new String[taxInfoList.length()];
				
				for(int i=0; i<taxInfoList.length(); i++)
				{
					type[i] = carType.getJSONObject(i).getString("name");
					unitType[i] = carType.getJSONObject(i).getString("unit");
					car_type_code[i] = carType.getJSONObject(i).getString("code");
				}
				*/
				year.setText(taxInfoList.getJSONObject(0).getString("year") + "年");
				tax_amount.setText(taxInfoList.getJSONObject(0).getString("yzje")+ "元");
				delay_amount.setText(taxInfoList.getJSONObject(0).getString("znje")+ "元");
				fine_amount.setText(taxInfoList.getJSONObject(0).getString("fkje")+ "元");
				if(taxInfoList.getJSONObject(0).getString("sfbj").equals("0"))
					bujiao.setText("否");
				else
					bujiao.setText("是");
			}
			else
			{
				Toast msg = Toast.makeText(this, data.getString("queryMsg"), Toast.LENGTH_LONG);
				msg.show();
			}
			
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}



	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		//getMenuInflater().inflate(R.menu.activity_mian, menu);
		menu.add(0, MY_NOTICE, 0, "我的通知");
		menu.add(0, NAV_SETTING, 0, "导航设置");
		menu.add(0, ACCOUNT_SETTING, 0, "账号设置");
		menu.add(0, INDIVIDUAL_SETTING, 0, "个性化设置");
		return true;
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem mi)
	{
		
		
		//判断单击的是哪个菜单项，并针对性的作出响应。
		switch (mi.getItemId())
		{
			case android.R.id.home:
				this.finish();
				break;
			case MY_NOTICE:
				Log.d("hehe","heh");
				Toast toast1 = Toast.makeText(getApplicationContext(),
					     "MY_NOTICE", Toast.LENGTH_SHORT);
				toast1.show();
				break;
			case NAV_SETTING:
				Toast toast2 = Toast.makeText(getApplicationContext(),
					     "NAV_SETTING", Toast.LENGTH_SHORT);
				toast2.show();;
				break;
			case ACCOUNT_SETTING:
				Toast toast3 = Toast.makeText(getApplicationContext(),
					     "ACCOUNT_SETTING", Toast.LENGTH_SHORT);
				toast3.show();
				break;
			case INDIVIDUAL_SETTING:
				Toast toast4 = Toast.makeText(getApplicationContext(),
					     "INDIVIDUAL_SETTING", Toast.LENGTH_SHORT);
				toast4.show();
				break;

		}
		return true;
	}
}
